package uk.ac.cam.echo.reader;

public class UI {
	
	public static final char EOP_CHAR = '\n';
	private static final int BAUDRATE = 9600;
	private static final int MAXLENGTH = 20;
	private static final String LED_RED_ON = "15";
	private static final String LED_GREEN_ON = "6";
	private static final String LEDS_OFF = "16";
	private static final String BELL = "7";
	
	private Communicator comm;
	
	public UI(String portName) {
		comm = new Communicator(portName, UI.BAUDRATE);
		comm.setPacketFormat(RFID1.EOP_CHAR);	
	}
	
	public void display(String text){
//		
//		String output = "";		
//		String[] words = text.split(" ");
//		
//		for (String w: words){
//			if (output.length() + w.length() > UI.MAXLENGTH)
//				output += "\n";
//			output += w + " ";
//		}
//		System.out.println(output);
//		comm.send(output);		
		comm.send("\r\n" + text);
	}
	
	public void ledsOff() {
		comm.sendSingleHexByte(UI.LEDS_OFF);
	}
	
	public void ledRedOn() {
		comm.sendSingleHexByte(UI.LED_RED_ON);
	}
	public void ledGreenOn() {
		comm.sendSingleHexByte(UI.LED_GREEN_ON);
	}
	
	public void bell() {
		comm.sendSingleHexByte(UI.BELL);
	}
}